//go:build wireinject
// +build wireinject

package wire

import (
	"github.com/google/wire"
	"github.com/spf13/viper"
	"golang-sgg-daijia/internal/handler"
	"golang-sgg-daijia/internal/handler/customer"
	"golang-sgg-daijia/internal/handler/driver"
	"golang-sgg-daijia/internal/repository/minio"
	"golang-sgg-daijia/internal/repository/mongodb"
	"golang-sgg-daijia/internal/repository/mysql"
	"golang-sgg-daijia/internal/repository/rabbitmq"
	"golang-sgg-daijia/internal/repository/redis"
	"golang-sgg-daijia/internal/repository/tencentcloud"
	"golang-sgg-daijia/internal/repository/tencentmap"
	"golang-sgg-daijia/internal/repository/wechat"
	"golang-sgg-daijia/internal/server"
	"golang-sgg-daijia/internal/service"
	"golang-sgg-daijia/pkg/app"
	"golang-sgg-daijia/pkg/jwt"
	"golang-sgg-daijia/pkg/log"
	"golang-sgg-daijia/pkg/server/http"
	"golang-sgg-daijia/pkg/sid"
)

var repositorySet = wire.NewSet(
	mysql.NewDB,
	redis.NewRedis,
	rabbitmq.NewRabbitMqProducer,
	wechat.NewWeChatMini,
	wechat.NewWeChatPay,
	tencentcloud.NewCosCli,
	tencentcloud.NewOcrCli,
	tencentcloud.NewIaiCli,
	tencentmap.NewMapClient,
	mongodb.NewMongoClient,
	minio.NewMinioCli,

	mysql.NewMysqlClient,
	mysql.NewTransaction,
	redis.NewRedisClient,
	wechat.NewWeChatMiniCli,
	wechat.NewWeChatPayCli,
	tencentcloud.NewCosClient,
	tencentcloud.NewOcrClient,
	tencentcloud.NewIaiClient,
	minio.NewMinioClient,
	rabbitmq.NewMqProducer,

	mysql.NewCustomerInfoDao,
	mysql.NewCustomerLoginLogDao,

	mysql.NewDriverInfoDao,
	mysql.NewDriverSetDao,
	mysql.NewDriverAccountDao,
	mysql.NewDriverAccountDetailDao,
	mysql.NewDriverLoginLogDao,
	mysql.NewDriverFaceRecognitionDao,
	mysql.NewOrderInfoDao,
	mysql.NewOrderJobDao,
	mysql.NewOrderBillDao,
	mysql.NewOrderProfitsharingDao,
	mysql.NewPaymentInfoDao,

	mongodb.NewOrderServiceLocationDao,
	mongodb.NewOrderMonitorRecordDao,
)

var serviceSet = wire.NewSet(
	service.NewService,

	service.NewCustomerInfoService,
	service.NewDriverService,
	service.NewCosService,
	service.NewOcrService,
	service.NewOrderService,
	service.NewLocationService,
	service.NewFileService,
	service.NewMonitorService,
	service.NewPaymentService,
	service.NewMqConsumer,
)

var handlerSet = wire.NewSet(
	handler.NewHandler,
	handler.NewCallbackHandler,

	customer.NewCustomerHandler,
	customer.NewOrderHandler,
	customer.NewCouponHandler,


	driver.NewDriverHandler,
	driver.NewCosHandler,
	driver.NewFileHandler,
	driver.NewLocationHandler,
	driver.NewMonitorHandler,
	driver.NewOcrHandler,
	driver.NewOrderHandler,
)

var serverSet = wire.NewSet(
	server.NewHTTPServer,
	server.NewJob,
)

// build App
func newApp(
	httpServer *http.Server,
	job *server.Job,
	// task *server.Task,
) *app.App {
	return app.NewApp(
		app.WithServer(httpServer, job),
		app.WithName("demo-server"),
	)
}

func NewWire(*viper.Viper, *log.Logger) (*app.App, func(), error) {
	panic(wire.Build(
		repositorySet,
		serviceSet,
		handlerSet,
		serverSet,
		sid.NewSid,
		jwt.NewJwt,
		newApp,
	))
}
